<template>
  <t-dialog
    :header="`${header}-微创新成果详情`"
    :visible.sync="visible"
    :onClose="closeDialog"
    :closeOnOverlayClick="false"
    :confirmBtn="null"
    width="80%"
    top="5%"
  >
    <div style="height: 65vh">
      <t-sticky-tool
        v-if="!hideInfo"
        :style="{ position: 'absolute', overflow: 'hidden',zIndex: 1000 }"
        :offset="[-30, 60]"
        @click="createPDF()"
      >
        <t-sticky-item  style="width: 80px" label="导出PDF" >
          <template #icon>
            <t-icon name="file-pdf"></t-icon>
          </template>
        </t-sticky-item>
      </t-sticky-tool>
      <innovation-detail :objId="objId">
      </innovation-detail>
    </div>
  </t-dialog>
</template>

<script>
import innovationDetail from "./innovation-detail.vue";
export default {
  name: "innovation-detail-dialog",
  components:{
    innovationDetail
  },
  props:{
    objId: [String,Number],
    header: String,
  },
  data(){
    return {
      visible: true,
      hideInfo: this.$store.state.user.roles.includes("wcxXssc"),
    }
  },
  methods:{
    createPDF(){
      const instance = this.$loading({
        fullscreen: true,
        attach: 'body',
        preventScrollThrough: false,
      });
      this.$api.wcx.apply.innovationPdf(this.objId).then(response => {
        window.open(response.data.fullFilePath, '_blank')
        instance.hide();
      }).catch((e) => {
        instance.hide();
        this.$message.error(e.toString());
      });
    },

    closeDialog() {
      this.$emit("update:visible", false);
    },
  }
}
</script>

<style scoped>

</style>
